package com.zhongnan.Demo3_Date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class NewDateJdk8 {
    public static void main(String[] args) throws ParseException {
        // LocalDateTime只能对有时分秒的时间进行操作
        String date = "2020/02/02 00:00:00";
        DateTimeFormatter newdate = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
        LocalDateTime local = LocalDateTime.parse(date, newdate);
        LocalDateTime localDateTime = local.plusDays(1);
        String format = localDateTime.format(newdate);
        System.out.println(format);
        // 获取当前时间
        // 年月日时分秒
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        // 年月日
        LocalDate now1 = LocalDate.now();
        System.out.println(now1);
        // 时分秒
        LocalTime now2 = LocalTime.now();
        System.out.println(now2);
    }

    private static void newDate() throws ParseException {
        String date = "2020/02/02";
        SimpleDateFormat newdate = new SimpleDateFormat("yyyy/MM/dd");
        Date parse = newdate.parse(date);
        long pas = parse.getTime() + (1000*60*60*24);
        Date date1 = new Date(pas);
        String format = newdate.format(date1);
        System.out.println(format);
    }
}
